import 'dart:convert';

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
import 'package:get/get.dart';
import 'package:wallet_utils/color.dart';
import 'package:wallet_utils/dialog/info_dialog.dart';
import 'package:wallet_utils/ht_appbar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wallet_utils/ht_common_widgets.dart';
import 'package:wallet_utils/log_util.dart';
import 'package:wallet_utils/number_text_input_matter.dart';
import 'package:wallet_utils/report_widget/click_widget.dart';
import 'package:wallet_utils/safe_bottom_view.dart';
import 'package:wallet_utils/text_style.dart';
import 'package:wallet_utils/webview_common.dart';
import '../../mine/contentType.dart';
import '../bean/controlBean.dart';
import 'logic.dart';
import 'package:flutter_pickers/pickers.dart';

class BasicInfoPage extends StatelessWidget {
  final logic = Get.put(BasicInfoLogic());
  final state = Get.find<BasicInfoLogic>().state;

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () {
        infoDialog();
        return Future.value(true);
      },
      child: Scaffold(
        backgroundColor: ColorManager.colorFFFFFF,
        appBar: htCommonAppbar(context, title: '基本信息', leadingAction: () {
          infoDialog();
        }),
        bottomNavigationBar: setBottomButton(
          context,
          '确定，下一步',
          hasShadow: false,
          onPressed: logic.state.isComplete
              ? () async {
                 logic.submit();
                  // if (flag!) {
                  //   // if (state.countdownTime == 0) {
                  //   //   state.countdownTime = 5;
                  //   //   //开始倒计时
                  //   //   logic.startCountdownTimer();
                  //   // }
                  //   // submitBottomSheet();
                  //   logic.jumpPage();
                  // }else{
                  //   state.isAgreeUserPrivary=true;
                  //   logic.jumpPage();
                  // }
                  // buildShowModalBottomSheet(context);
                }
              : null,
        ),
        body: Container(
          height: double.infinity,
          decoration: BoxDecoration(
            gradient: LinearGradient(
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
              colors: [
                ColorManager.colorFBE9DD,
                ColorManager.colorF4F5F6,
                ColorManager.colorF4F5F6,
              ],
            ),
          ),
          child: SingleChildScrollView(
            child: Column(
              children: [
                GetBuilder<BasicInfoLogic>(builder: (logic) {
                  return Stack(
                    children: [
                      Container(
                        margin: EdgeInsets.only(top: 30.w, left: 16.w, right: 16.w),
                        child: Row(
                          children: [
                            InkWell(
                              onTap: () {},
                              child: Container(
                                child: Text(
                                  '总进度',
                                  style: TextStyleUtils.style343D54(fontSize: 14.sp, fontWeight: FontWeight.bold),
                                ),
                              ),
                            ),
                            SizedBox(
                              width: 10.w,
                            ),
                            Stack(
                              children: [
                                // 下面的背景盒子
                                Container(
                                  height: 4.w,
                                  width: 280.w,
                                  decoration: BoxDecoration(
                                    borderRadius: BorderRadius.all(Radius.circular(2.w)),
                                    color: ColorManager.colorFFFFFF,
                                  ),
                                ),
                                // 上面的进度条盒子
                                Container(
                                  height: 4.w,
                                  width: state.percent, // 动态更改进度条盒子的宽度即可
                                  decoration: BoxDecoration(
                                    borderRadius: BorderRadius.all(Radius.circular(15.w)),
                                    color: ColorManager.colorD93C3A,
                                  ),
                                ),
                              ],
                            ),
                          ],
                        ),
                      ),
                      Visibility(
                        visible: state.proState,
                        child: Container(
                          decoration: const BoxDecoration(
                            image: DecorationImage(
                              image: AssetImage("assets/icon_pro.png"),
                              fit: BoxFit.cover,
                            ),
                          ),
                          width: 25.w,
                          height: 15.w,
                          alignment: Alignment.center,
                          margin: EdgeInsets.only(
                            left: state.percent + 55.w,
                            top: 18.w,
                          ),
                          padding: EdgeInsets.only(bottom: 2.w),
                          child: Text(
                            state.proText,
                            style: TextStyleUtils.styleFFFFFF(fontSize: 10.sp),
                          ),
                        ),
                      ),
                    ],
                  );
                }),
                Container(
                  margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 30.w),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                        '资料填写',
                        style: TextStyleUtils.style000000(fontSize: 18.sp, fontWeight: FontWeight.bold),
                      ),
                      Container(
                        height: 26.w,
                        padding: EdgeInsets.only(left: 7.w, right: 7.w),
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.all(Radius.circular(13.w)),
                          color: ColorManager.colorFFFFFF.withAlpha(90),
                        ),
                        child: Row(
                          children: [
                            Image.asset(
                              'images/icon_location.png',
                              width: 10.w,
                              height: 12.w,
                            ),
                            SizedBox(
                              width: 3.w,
                            ),
                            GetBuilder<BasicInfoLogic>(builder: (logic) {
                              return Text(
                                '${state.province} ${state.city}',
                                style: TextStyleUtils.style000000(fontSize: 12.sp),
                              );
                            })
                          ],
                        ),
                      )
                    ],
                  ),
                ),
                Container(
                  margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 5.w),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                        '完善个人真实信息，确保资料充分',
                        style: TextStyleUtils.style666666(fontSize: 12.sp),
                      ),
                      ClickWidget(
                        onTap: () async {
                          Pickers.showAddressPicker(context, onConfirm: (p, c, t) {
                            state.province = p;
                            if (p == '北京市') {
                              state.city = state.province;
                            } else if (p == '天津市') {
                              state.city = state.province;
                            } else {
                              state.city = c;
                            }
                            logic.update();
                            LogUtils.d('省  ${state.province}   市${state.city}   区$t');
                          });
                        },
                        child: Container(
                            margin: EdgeInsets.only(right: 6.w),
                            child: Text(
                              '定位不准手动定位',
                              style: TextStyleUtils.style5166B2(fontSize: 10.sp),
                            )),
                      )
                    ],
                  ),
                ),
                //姓名
                GetBuilder<BasicInfoLogic>(builder: (logic) {
                  return Visibility(
                    visible: state.isShowName!,
                    child: Container(
                      margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 10.w),
                      padding: EdgeInsets.only(left: 10.w, right: 10.w, top: 15.w, bottom: 15.w),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.all(Radius.circular(5.w)),
                        color: ColorManager.colorFFFFFF,
                      ),
                      child: Column(
                        children: [
                          Row(
                            children: [
                              Text('真实姓名', style: TextStyleUtils.style000000(fontSize: 15.sp)),
                              Expanded(
                                child: TextField(
                                  controller: state.nameController,
                                  maxLines: 10,
                                  minLines: 1,
                                  autocorrect: true,
                                  cursorColor: ColorManager.color4375DD,
                                  textAlign: TextAlign.right,
                                  keyboardType: TextInputType.text,
                                  textAlignVertical: TextAlignVertical.center,
                                  style: TextStyleUtils.style000000(fontSize: 15.sp),
                                  decoration: InputDecoration(
                                    isDense: true,
                                    contentPadding: EdgeInsets.only(bottom: 0.w),
                                    border: InputBorder.none,
                                    hintText: '请输入您的真实姓名',
                                    hintStyle: TextStyleUtils.style999999(fontSize: 15.sp),
                                  ),
                                  onChanged: (text) => LogUtils.d('change $text'),
                                  onSubmitted: (text) => LogUtils.d('submit $text'),
                                  enabled: logic.isEditContent(),
                                ),
                              )
                            ],
                          ),
                        ],
                      ),
                    ),
                  );
                }),
                //身份证号
                GetBuilder<BasicInfoLogic>(builder: (logic) {
                  return Visibility(
                    visible: state.isShowIdCard!,
                    child: Container(
                      margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 10.w),
                      padding: EdgeInsets.only(left: 10.w, right: 10.w, top: 15.w, bottom: 15.w),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.all(Radius.circular(5.w)),
                        color: ColorManager.colorFFFFFF,
                      ),
                      child: Column(
                        children: [
                          Row(
                            children: [
                              Text('身份证号', style: TextStyleUtils.style000000(fontSize: 15.sp)),
                              Expanded(
                                child: TextField(
                                  controller: state.idCardController,
                                  maxLines: 10,
                                  minLines: 1,
                                  autocorrect: true,
                                  cursorColor: ColorManager.color4375DD,
                                  textAlign: TextAlign.right,
                                  keyboardType: TextInputType.text,
                                  textAlignVertical: TextAlignVertical.center,
                                  style: TextStyleUtils.style000000(fontSize: 15.sp),
                                  decoration: InputDecoration(
                                    isDense: true,
                                    contentPadding: EdgeInsets.only(bottom: 0.w),
                                    border: InputBorder.none,
                                    hintText: '请输入身份证号码',
                                    hintStyle: TextStyleUtils.style999999(fontSize: 15.sp),
                                  ),
                                  onChanged: (text) => LogUtils.d('change $text'),
                                  onSubmitted: (text) => LogUtils.d('submit $text'),
                                  enabled: logic.isEditContent(),
                                ),
                              )
                            ],
                          ),
                        ],
                      ),
                    ),
                  );
                }),
                //年龄
                GetBuilder<BasicInfoLogic>(builder: (logic) {
                  return Visibility(
                    visible: state.isShowAge!,
                    child: Container(
                      margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 10.w),
                      padding: EdgeInsets.only(left: 10.w, right: 10.w, top: 15.w, bottom: 15.w),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.all(Radius.circular(5.w)),
                        color: ColorManager.colorFFFFFF,
                      ),
                      child: Column(
                        children: [
                          Row(
                            children: [
                              Text('年龄', style: TextStyleUtils.style000000(fontSize: 15.sp)),
                              Expanded(
                                child: TextField(
                                  controller: state.ageController,
                                  maxLines: 10,
                                  minLines: 1,
                                  autocorrect: true,
                                  cursorColor: ColorManager.color4375DD,
                                  textAlign: TextAlign.right,
                                  keyboardType: TextInputType.number,
                                  textAlignVertical: TextAlignVertical.center,
                                  style: TextStyleUtils.style000000(fontSize: 15.sp),
                                  decoration: InputDecoration(
                                    isDense: true,
                                    contentPadding: EdgeInsets.only(bottom: 0.w),
                                    border: InputBorder.none,
                                    hintText: '年龄在22岁-55岁均可申请',
                                    hintStyle: TextStyleUtils.style999999(fontSize: 15.sp),
                                  ),
                                  onChanged: (text) => LogUtils.d('change $text'),
                                  onSubmitted: (text) => LogUtils.d('submit $text'),
                                  enabled: logic.isEditContent(),
                                ),
                              )
                            ],
                          ),
                        ],
                      ),
                    ),
                  );
                }),
                GetBuilder<BasicInfoLogic>(builder: (logic) {
                  return Visibility(
                    visible: state.isShowMonthIncome!,
                    child: Container(
                      margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 10.w),
                      padding: EdgeInsets.only(left: 10.w, right: 10.w, top: 15.w, bottom: 15.w),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.all(Radius.circular(5.w)),
                        color: ColorManager.colorFFFFFF,
                      ),
                      child: Column(
                        children: [
                          Row(
                            children: [
                              Text('月收入', style: TextStyleUtils.style000000(fontSize: 15.sp)),
                              Expanded(
                                child: TextField(
                                  controller: state.monthIncomeController,
                                  maxLines: 10,
                                  minLines: 1,
                                  autocorrect: true,
                                  cursorColor: ColorManager.color4375DD,
                                  textAlign: TextAlign.right,
                                  keyboardType: TextInputType.number,
                                  textAlignVertical: TextAlignVertical.center,
                                  style: TextStyleUtils.style000000(fontSize: 15.sp),
                                  inputFormatters:[NumberTextInputFormatter(
                                      maxDecimalLength:2,
                                  )],
                                  decoration: InputDecoration(
                                    isDense: true,
                                    contentPadding: EdgeInsets.only(bottom: 0.w),
                                    border: InputBorder.none,
                                    hintText: '请输入月收入',
                                    hintStyle: TextStyleUtils.style999999(fontSize: 15.sp),
                                  ),
                                  onChanged: (text) => LogUtils.d('change $text'),
                                  onSubmitted: (text) => LogUtils.d('submit $text'),
                                ),
                              )
                            ],
                          ),
                        ],
                      ),
                    ),
                  );
                }),

                GetBuilder<BasicInfoLogic>(builder: (logic) {
                  return MediaQuery.removePadding(
                    context: context,
                    removeTop: true,
                    child: ListView.builder(
                      shrinkWrap: true,
                      itemCount: state.controlList.length,
                      physics: const NeverScrollableScrollPhysics(),
                      itemBuilder: ((context, index) {
                        return basicInfoWidget(index);
                      }),
                    ),
                  );
                })
              ],
            ),
          ),
        ),
      ),
    );
  }

  Future<dynamic> buildShowModalBottomSheet() {
    return showModalBottomSheet(
        context: Get.context!,
        enableDrag:false,
        isDismissible: false,
        isScrollControlled: false,
        shape: const RoundedRectangleBorder(
            borderRadius: BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15))),
        builder: (BuildContext buildContext) {
          return Container(
            height: 470.w,
            decoration: const BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15))),
            child: Column(
              children: [
                Container(
                    alignment: Alignment.centerLeft,
                    margin: EdgeInsets.only(top: 15.w, left: 16.w, bottom: 20.w),
                    child: Image.asset(
                      'images/auth_reco_logo.png',
                      width: 44.w,
                      height: 10.w,
                    )),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Image.asset(
                      'images/icon_complete.png',
                      width: 20.w,
                      height: 20.w,
                    ),
                    SizedBox(
                      width: 10.w,
                    ),
                    Text(
                      '恭喜您，已通过初审',
                      style: TextStyleUtils.style000000(fontSize: 16.sp, fontWeight: FontWeight.bold),
                    ),
                  ],
                ),
                Container(
                  height: 105.w,
                  width: double.infinity,
                  margin: EdgeInsets.only(left: 16.w, right: 16.w, bottom: 10.w),
                  decoration: BoxDecoration(
                    color: ColorManager.colorFFFFFF,
                    //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                    borderRadius: BorderRadius.all(Radius.circular(5.0)),
                  ),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Text(
                        '${state.amount}元',
                        style: TextStyleUtils.styleFFECE9(fontSize: 32.sp, fontWeight: FontWeight.bold),
                      ),
                      Text(
                        '您的借款将由合作方${state.name}提供',
                        style: TextStyleUtils.style666666(fontSize: 12.sp),
                      )
                    ],
                  ),
                ),
                Container(
                  width: double.infinity,
                  alignment: Alignment.center,
                  margin: EdgeInsets.only(left: 15.w, right: 15.w,bottom: 15.w,),
                  padding: EdgeInsets.only(left: 8.w, right: 8.w,top: 10.w,bottom: 10.w),
                  decoration: BoxDecoration(
                    color: ColorManager.colorFFF7F2,
                    //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                    borderRadius: BorderRadius.all(Radius.circular(5.0)),
                  ),
                  height: 150.w,
                  child: MediaQuery.removePadding(
                    removeTop: true,
                    context:Get.context!,
                    child: ListView(
                      shrinkWrap: true,
                      children: [
                        HtmlWidget(
                          state.content ?? '',
                          textStyle: TextStyleUtils.style000000(fontSize: 13.sp),
                        ),
                      ],
                    ),
                  ),
                ),
                ClickWidget(
                  onTap: () {
                    Get.to(WebViewCommon(
                      state.popLinkUrl ?? '',
                    ));
                  },
                  child: Container(
                    width: double.infinity,
                    height: 48.w,
                    alignment: const Alignment(0, 0),
                    margin: EdgeInsets.only(right: 16.w, left: 16.w, top: 7.w),
                    decoration: BoxDecoration(
                      color: ColorManager.colorD93C3A,
                      //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                      borderRadius: BorderRadius.all(Radius.circular(25.0)),
                    ),
                    child: Text(
                      '申请提现',
                      style: TextStyleUtils.styleFFFFFF(fontSize: 16.sp, fontWeight: FontWeight.bold),
                    ),
                  ),
                ),
                ClickWidget(
                  onTap: () {
                    state.isBack=true;
                    Get.back();
                    // logic.backPage();
                  },
                  child: Container(
                    margin: EdgeInsets.only(top: 20.w),
                    child: Text(
                      '放弃借款',
                      style: TextStyleUtils.style666666(fontSize: 16.sp, fontWeight: FontWeight.bold),
                    ),
                  ),
                )
              ],
            ),
          );
        });
  }

  Widget basicInfoWidget(int index) {
    return Container(
      margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 10.w),
      padding: EdgeInsets.only(left: 10.w, right: 10.w, top: 15.w),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(Radius.circular(5.w)),
        color: ColorManager.colorFFFFFF,
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            margin: EdgeInsets.only(bottom: 20.w),
            child: Text(
              state.controlList[index].title ?? '',
              style: TextStyleUtils.style000000(fontSize: 16.sp),
            ),
          ),
          // Container(
          //   margin: EdgeInsets.only(top: 15.w, bottom: 10.w),
          //   child: Row(
          //     children: [
          //       Text('居住地址', style: TextStyleUtils.style000000(fontSize: 15.sp)),
          //       Expanded(
          //         child: TextField(
          //           controller: state.controller,
          //           maxLines: 10,
          //           minLines: 1,
          //           autocorrect: true,
          //           cursorColor: ColorManager.color353535,
          //           textAlign: TextAlign.right,
          //           keyboardType: TextInputType.text,
          //           textAlignVertical: TextAlignVertical.center,
          //           style: TextStyleUtils.style000000(fontSize: 15.sp),
          //           decoration: InputDecoration(
          //             isDense: true,
          //             contentPadding: EdgeInsets.only(bottom: 0.w),
          //             border: InputBorder.none,
          //             hintText: '请输入居家地址',
          //             hintStyle: TextStyleUtils.style999999(fontSize: 15.sp),
          //           ),
          //           onChanged: (text) => LogUtils.d('change $text'),
          //           onSubmitted: (text) => LogUtils.d('submit $text'),
          //           enabled: true,
          //         ),
          //       )
          //     ],
          //   ),
          // ),
          // Container(
          //   width: double.infinity,
          //   height: 0.5.w,
          //   margin: EdgeInsets.only(bottom: 20.w),
          //   color: ColorManager.colorECECEC,
          // ),
          GridView.builder(
            padding: EdgeInsets.zero,
            shrinkWrap: true,
            physics: const NeverScrollableScrollPhysics(),
            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 3,
              mainAxisSpacing: 15.w,
              crossAxisSpacing: 10.w,
              childAspectRatio: 1.8,
            ),
            itemCount: state.controlList[index].childData?.length,
            itemBuilder: (BuildContext context, int position) {
              return buildItem(state.controlList[index].childData![position], context, position, index);
            },
          ),
          SizedBox(
            height: 20.w,
          ),
          // Container(
          //   margin: EdgeInsets.only(top: 20.w, bottom: 10.w),
          //   child: Row(
          //     children: [
          //       Text('居住地址', style: TextStyleUtils.style000000(fontSize: 15.sp)),
          //       Expanded(
          //         child: TextField(
          //           controller: state.controller,
          //           maxLines: 10,
          //           minLines: 1,
          //           autocorrect: true,
          //           cursorColor: ColorManager.color353535,
          //           textAlign: TextAlign.right,
          //           keyboardType: TextInputType.text,
          //           textAlignVertical: TextAlignVertical.center,
          //           style: TextStyleUtils.style000000(fontSize: 15.sp),
          //           decoration: InputDecoration(
          //             isDense: true,
          //             contentPadding: EdgeInsets.only(bottom: 0.w),
          //             border: InputBorder.none,
          //             hintText: '请输入居家地址',
          //             hintStyle: TextStyleUtils.style999999(fontSize: 15.sp),
          //           ),
          //           onChanged: (text) => LogUtils.d('change $text'),
          //           onSubmitted: (text) => LogUtils.d('submit $text'),
          //           enabled: true,
          //         ),
          //       )
          //     ],
          //   ),
          // ),
          Visibility(
            visible: false,
            child: Container(
              width: double.infinity,
              height: 0.5.w,
              color: ColorManager.colorECECEC,
            ),
          ),
        ],
      ),
    );
  }

  Widget buildItem(ChildData? childInfo, BuildContext context, int position, int index) {
    return ClickWidget(
      onTap: () {
        FocusScope.of(context).requestFocus(FocusNode());
        logic.isCheckStatus(position, index);
      },
      child: Container(
        height: 42.w,
        alignment: Alignment.center,
        decoration: BoxDecoration(
          color: ColorManager.colorF8F9FA,
          //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
          borderRadius: const BorderRadius.all(Radius.circular(4.0)),
          border: Border.all(width: 1, color: childInfo?.isSelect == true ? ColorManager.colorD93C3A : ColorManager.colorF8F9FA),
        ),
        child: Text(
          childInfo?.name ?? '',
          style: childInfo?.isSelect == true
              ? TextStyleUtils.styleD93C3A(fontSize: 13.sp)
              : TextStyleUtils.style333333(fontSize: 13.sp),
        ),
      ),
    );
  }

  void infoDialog() {
    if(!state.isBack){
      showDialog(
          context: Get.context!,
          builder: (context) {
            return InfoDialog(
              "放弃填写，将无法评估您的额度",
              title: '温馨提示',
              yesStr: '继续填写资料',
              yesCallback: () {
                Get.back();
              },
              backCallback: () {
                Get.back();
                if(logic.popUpsInfo.isNotEmpty){
                  buildShowModalBottomSheet();
                }else{
                  logic.backPage();
                }
              },
            );
          });
    }else{
      logic.backPage();
    }
  }

  Future<dynamic> submitBottomSheet() {
    return showModalBottomSheet(
        context: Get.context!,
        isDismissible: false,
        isScrollControlled: false,
        shape: const RoundedRectangleBorder(
            borderRadius: BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15))),
        builder: (BuildContext buildContext) {
          return GetBuilder<BasicInfoLogic>(builder: (logic) {
            return Container(
              height: 486.w,
              decoration: const BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15))),
              child: Column(
                children: [
                  Container(
                      margin: EdgeInsets.only(top: 20.w, bottom: 5.w),
                      child: Text(
                        '有专业机构愿意优先为您服务',
                        style: TextStyleUtils.style000000(
                          fontSize: 18.sp,
                          fontWeight: FontWeight.bold,
                        ),
                      )),
                  Text(
                    '98%的用户通过咨询该机构成功下款',
                    style: TextStyleUtils.colorFF0000(fontSize: 12.sp),
                  ),
                  Expanded(
                    child: ListView.builder(
                      shrinkWrap: true,
                      itemCount: 1,
                      physics: const NeverScrollableScrollPhysics(),
                      itemBuilder: ((context, index) {
                        return serviceItem(index);
                      }),
                    ),
                  ),
                  Visibility(
                    visible: false,
                    child: Container(
                      margin: EdgeInsets.only(bottom: 50.w),
                      child: Text(
                        '${state.countdownTime}秒后关闭',
                        style: TextStyleUtils.colorFF0000(fontSize: 16.sp),
                      ),
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.only(left: 30.w, top: 24.w),
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        Padding(
                          padding: EdgeInsets.only(right: 5.w),
                          child: GestureDetector(
                            behavior: HitTestBehavior.opaque,
                            onTap: () {
                              state.isAgreeUserPrivary = !(state.isAgreeUserPrivary);
                              logic.update();
                            },
                            child: Container(
                              width: 16.w,
                              height: 16.w,
                              margin: const EdgeInsets.only(top: 4),
                              alignment: Alignment.center,
                              child: state.isAgreeUserPrivary
                                  ? Image.asset(
                                      "images/ic_agreement_checked.png",
                                      width: 11.w,
                                      height: 11.w,
                                    )
                                  : Image.asset(
                                      "images/ic_agreement_unchecked.png",
                                      width: 11.w,
                                      height: 11.w,
                                    ),
                            ),
                          ),
                        ),
                        Expanded(
                          child: Text.rich(
                            TextSpan(
                              children: <InlineSpan>[
                                TextSpan(
                                    text: "我已阅读并同意",
                                    style: TextStyleUtils.style999999(fontSize: 11.sp),
                                    recognizer: TapGestureRecognizer()..onTap = () {}),
                                TextSpan(
                                  text: "《个人信息查询授权书》",
                                  style: TextStyle(color: ColorManager.color437EFF, fontSize: 11.sp, height: 1.5.w),
                                  // 设置点击事件
                                  recognizer: TapGestureRecognizer()
                                    ..onTap = () {
                                      logic.getUserInfo(ContentType.personalCredit);
                                    },
                                ),
                              ],
                            ),
                            style: TextStyle(
                              color: ColorManager.color999999,
                              fontSize: 13.sp,
                              height: 1.5,
                            ),
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                          ),
                        ),
                      ],
                    ),
                  ),
                  ClickWidget(
                    onTap: () {
                      // Get.back();
                      // state.timer.cancel();
                      logic.jumpPage();
                    },
                    child: Container(
                      width: double.infinity,
                      height: 48.w,
                      alignment: const Alignment(0, 0),
                      margin: EdgeInsets.only(right: 16.w, left: 16.w, top: 20.w, bottom: ScreenUtil().bottomBarHeight + 10.w),
                      decoration: BoxDecoration(
                        color: ColorManager.colorD93C3A,
                        //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                        borderRadius: BorderRadius.all(Radius.circular(25.0)),
                      ),
                      child: Text(
                        '同意协议并申请',
                        style: TextStyleUtils.styleFFFFFF(fontSize: 16.sp, fontWeight: FontWeight.bold),
                      ),
                    ),
                  ),
                ],
              ),
            );
          });
        });
  }

  Widget serviceItem(int index) {
    return Container(
      height: 105.w,
      width: double.infinity,
      margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 19.w, bottom: 15.w),
      decoration: BoxDecoration(
        color: ColorManager.colorF3F7FF,
        //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
        borderRadius: BorderRadius.all(Radius.circular(5.0)),
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Container(
            margin: EdgeInsets.only(left: 10.w, right: 10.w),
            child: Row(
              children: [
                HtImage(
                    icon: true,
                    url: logic.isStatus() ? logic.offlineProduct?.defaultIcon : logic.product?.defaultIcon,
                    width: 18.w,
                    height: 18.w,
                    radius: 2),
                SizedBox(
                  width: 5.w,
                ),
                Text(
                  (logic.isStatus() ? logic.offlineProduct?.productName : logic.product?.productName) ?? '',
                  style: TextStyleUtils.style000000(fontSize: 14.sp, fontWeight: FontWeight.bold),
                ),
              ],
            ),
          ),
          Row(
            children: [
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Container(
                    margin: EdgeInsets.only(left: 10.w, top: 11.w),
                    child: Text(
                      (logic.isStatus() ? logic.offlineProduct?.loanAmount : logic.product?.loanAmount) ?? '',
                      style: TextStyleUtils.styleF73326(fontSize: 14.sp, fontWeight: FontWeight.bold),
                      textAlign: TextAlign.left,
                    ),
                  ),
                  Container(
                      margin: EdgeInsets.only(left: 10.w, top: 3.w),
                      child: Text(
                        '最高可借(元)',
                        style: TextStyleUtils.style999999(fontSize: 12.sp),
                      )),
                ],
              ),
              Container(
                margin: EdgeInsets.symmetric(horizontal: 15.w),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      margin: EdgeInsets.only(left: 10.w, top: 11.w),
                      child: Text(
                        (logic.isStatus() ? logic.offlineProduct?.loanPeriod : logic.product?.loanPeriod) ?? '',
                        style: TextStyleUtils.style000000(fontSize: 14.sp, fontWeight: FontWeight.bold),
                        textAlign: TextAlign.left,
                      ),
                    ),
                    Container(
                        margin: EdgeInsets.only(left: 10.w, top: 3.w),
                        child: Text(
                          '借款期限(月)',
                          style: TextStyleUtils.style999999(fontSize: 12.sp),
                        )),
                  ],
                ),
              ),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Container(
                    margin: EdgeInsets.only(left: 10.w, top: 11.w),
                    child: Text(
                      '${logic.isStatus() ? logic.offlineProduct?.loanRate : logic.product?.loanRate}%',
                      style: TextStyleUtils.style000000(fontSize: 14.sp, fontWeight: FontWeight.bold),
                      textAlign: TextAlign.left,
                    ),
                  ),
                  Container(
                      margin: EdgeInsets.only(left: 10.w, top: 3.w),
                      child: Text(
                        '年利率',
                        style: TextStyleUtils.style999999(fontSize: 12.sp),
                      )),
                ],
              )
            ],
          )
        ],
      ),
    );
  }
}
